package com.zs.propertymanage.controller;

import com.zs.propertymanage.annotation.SystemLog;
import com.zs.propertymanage.dataObj.R;
import com.zs.propertymanage.dataObj.entity.Org;
import com.zs.propertymanage.service.impl.OrgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/org")
@CrossOrigin
public class OrgController {

    @Autowired
    private OrgService orgService;

    // 获取所有组织(整合过的)
    @GetMapping("")
    @ResponseBody
    public R getOrg(String search, Integer currentPage, Integer pageSize) {
        return orgService.getOrg(search, currentPage, pageSize);
    }

    // 新增组织
    @PostMapping("")
    @ResponseBody
    @SystemLog(name = "添加组织")
    public R createOrg(@RequestBody Org Org) {
        return orgService.createOrg(Org);
    }

    // 编辑组织
    @PutMapping("")
    @ResponseBody
    @SystemLog(name = "编辑组织")
    public R updateOrg(@RequestBody Org org) {
        return orgService.updateOrg(org);
    }

    // 删除组织
    @DeleteMapping("/{orgId}")
    @ResponseBody
    @SystemLog(name = "删除组织")
    public R deleteOrg(@PathVariable Integer orgId) {
        return orgService.deleteOrg(orgId);
    }


}
